package com.noqueue.action.eateryadmin;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.ParentPackage;

import com.noqueue.service.AdminService;
import com.noqueue.service.QueueService;

/**
 * Action 排队类
 * 
 * @author Bob.Ren
 * @date 2013-7-3
 */
@ParentPackage("admin")
public class QueueAction extends BaseAction {

	private static final long serialVersionUID = -4276446217262552805L;
	public static final String EATERY_ID = "EATERY_ID";

	@Resource
	private QueueService queueService;
	@Resource
	private AdminService adminService;

	// 查看
	public String view() {
		// payment = paymentService.load(id);
		return VIEW;
	}

	// 列表
	public String list() {
		String eateryId = ((String) getSession(EATERY_ID)).toLowerCase();
		setId(eateryId);
		pager = queueService.loadQueueListPagerByEateryId(id);
		return LIST;
	}

	// 删除
	public String delete() {
		// paymentService.delete(ids);
		return ajaxJsonSuccessMessage("删除成功！");
	}

	public String ready() {
		String eateryId = ((String) getSession(EATERY_ID)).toLowerCase();
		setId(eateryId);
		if (queueService.settleAccount(id)) {
			return ajaxJsonSuccessMessage("结账成功！");
		} else {
			return ajaxJsonSuccessMessage("结账失败，请重试！");
		}

	}

}